package com.example.demo.security;

import javax.servlet.http.HttpServletRequest;
import org.springframework.security.web.authentication.WebAuthenticationDetails;

/**
 * @author xkx
 * @version 1.0.0
 * @datetime 2019/2/11 18:14
 * @description
 */
public class CustomWebAuthenticationDetails extends WebAuthenticationDetails {

  private static final long serialVersionUID = 4813233371986328119L;

  private final String verifyCode;

  /**
   * Records the remote address and will also set the session Id if a session already exists (it
   * won't create one).
   *
   * @param request that the authentication request was received from
   */
  public CustomWebAuthenticationDetails(HttpServletRequest request) {
    super(request);
    this.verifyCode = request.getParameter("verifyCode");
  }

  public String getVerifyCode() {
    return verifyCode;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(super.toString()).append("; VerifyCode: ").append(this.getVerifyCode());
    return sb.toString();
  }
}
